from django.db import models

#基类
class Base(models.Model):
    id = models.AutoField(primary_key=True)

    class Meta:
        abstract = True



#订单表
class Orders(Base):

    #订单id
    orderid = models.CharField(max_length=500)
    #用户uid
    uid = models.IntegerField()
    #价格
    price = models.IntegerField()
    #支付状态
    state = models.IntegerField(default=0)
    #课程明细
    cids = models.CharField(max_length=500)

    class Meta:
        db_table = 'orders'


#优惠卷
class Codes(Base):

    #随机码
    code = models.CharField(max_length=500)
    #折扣
    discount = models.FloatField()
    #是否过期
    state = models.IntegerField(default=1)

    class Meta:

        db_table = 'codes'

#关注表
class Flows(Base):

    #用户id
    uid = models.IntegerField()
    #课程id
    cid = models.IntegerField()

    class Meta:
        db_table = "flows"


#留言表
class Comment(Base):

    #评论内容
    content = models.CharField(max_length=500)
    #课程id
    cid = models.IntegerField()

    class Meta:
        db_table = "comment"

#用户表
class User(Base):

    #用户名
    username = models.CharField(max_length=200)
    #密码
    password = models.CharField(max_length=100)
    #用户头像  设置上传路径
    img = models.ImageField(upload_to='static/upload/')
    #统计个人主页访问量
    num = models.IntegerField(default=0)

    #声明表名
    class Meta:
        db_table = "user"

#课程分类
class Category(Base):

    #分类名称
    name = models.CharField(max_length=200)

    class Meta:
        db_table = "category"

#课程表
class Course(Base):

    #课程标题
    title = models.CharField(max_length=200)
    #课程详情
    desc = models.CharField(max_length=500)
    #视频地址
    video = models.CharField(max_length=200)
    #价格
    price = models.IntegerField()
    #用户id
    uid = models.IntegerField()
    #类别
    cid = models.IntegerField()
    #关注数
    flow = models.IntegerField(default=0)

    class Meta:
        db_table = "course"



